package com.pablosz.worm;

import android.graphics.Canvas;

import com.pablosz.worm.util.Hashtable;
import com.pablosz.worm.util.LifecicleComponents;


public abstract class LifecicleComponent 
{
	private static final String LIFECICLE_DELAY = "lifecicleDelay";
	
	private Hashtable<Object> properties = null;
	
	public LifecicleComponent()
	{
		properties = new Hashtable<Object>();
	}
	
	public int getLifecicleDelay()
	{
		return (Integer)properties.getAndIfNull(LIFECICLE_DELAY, 0);
	}
	
	public void setLifecicleDelay(int d)
	{
		int lcd = Math.max(d, 0);
		properties.put(LIFECICLE_DELAY, lcd);
		
	}
	
	public void resetLifecicleDelay()
	{
		resetProperty(LIFECICLE_DELAY);
	}
	
	public void resetProperty(String name)
	{
		properties.resetValue(name);
	}
	
	public void setProperty(String name, Object value)
	{
		properties.put(name, value);
	}
	
	public Object getProperty(String name)
	{
		return properties.get(name);
	}
	
	public void resetProperties()
	{
		properties.resetValues();
	}
	
	public abstract void init(Lifecicle lf,LifecicleComponents components,long width,long height);
	public abstract void process(Lifecicle lf,LifecicleComponents  components,long width,long height);
	public abstract boolean finish(Lifecicle lf,LifecicleComponents  components,long width,long height);
	public abstract void print(Canvas canvas);
	
	// notificacion de touch
	public abstract void onTouch(Lifecicle lf,LifecicleComponents components,long x,long y);
	
}
